package com.collect.cameroon.zhiScene.zhiWidget.zhiDialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.collect.cameroon.R;
import com.collect.cameroon.zhiAdater.zhiPartRepay.ZHIPartRepayAdjuster;
import com.collect.cameroon.zhiBean.zhiReceive.ZHIRPartRepayListEntity;
import com.collect.cameroon.zhiScene.zhiWidget.zhiStepView.ZHINextStepView;

import java.util.ArrayList;


public class ZHIDialogPartRepay extends Dialog {

    private RecyclerView rc_list;
    private ZHINextStepView btn_close;

    private Context context;
    private ZHIPartRepayAdjuster mZHIPartRepayAdjuster = new ZHIPartRepayAdjuster();

    public ZHIDialogPartRepay(Context context) {
        super(context, R.style.CustomDialog);
        this.context = context;
    }

    public static ZHIDialogPartRepay showDataSource(Context context1, ArrayList<ZHIRPartRepayListEntity> arrayList){
        ZHIDialogPartRepay zhiDialogPartRepay = new ZHIDialogPartRepay(context1);
        zhiDialogPartRepay.showData(arrayList);
        return zhiDialogPartRepay;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_part_repay);
        setCanceledOnTouchOutside(false);
        initView();
        refreshViewData();
        initViewEvent();
    }

    @Override
    public void show() {
        super.show();
        refreshViewData();
    }

    private void initView() {

        btn_close = findViewById(R.id.btn_close);
        btn_close.setOnMenuItemDidChangedListener(item -> dismiss());

        rc_list = findViewById(R.id.rc_list);
        rc_list.setLayoutManager(new GridLayoutManager(context, 1));
        rc_list.setAdapter(mZHIPartRepayAdjuster);
    }

    public void showData(ArrayList<ZHIRPartRepayListEntity> arrayList) {
        mZHIPartRepayAdjuster.setNewData(arrayList);
        show();
    }

    private void refreshViewData() {

    }

    private void initViewEvent() {


    }

}
